package com.cnap.multiclouldmgmt.repository.master;

import com.cnap.multiclouldmgmt.model.k8sModels.EventModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author dyq
 * 对接数据库操作语句
 */
@Mapper
public interface K8sClusterEventsMapper {

    /**
     * 保存事件
     * @param eventModel
     */
    void addK8sClusterEvent(EventModel eventModel);

    /**
     * 获取事件数量
     * @param k8sClusterIp
     * @param userName
     * @param beginTime
     * @param reason
     * @return
     */
    int countK8sClusterEvents(@Param("k8sClusterIp")String k8sClusterIp,@Param("userName")String userName,@Param("beginTime") LocalDateTime beginTime,
                              @Param("reason") String reason,@Param("endTime") LocalDateTime endTime,
                              @Param("cloudVendor")String cloudVendor);

    /**
     * 按页获取事件
     * @param k8sClusterIp
     * @param userName
     * @param beginTime
     * @param reason
     * @param pageSize
     * @param offset
     * @return
     */
    List<EventModel> getK8sClusterEventsByPage(@Param("k8sClusterIp")String k8sClusterIp,@Param("userName")String userName,
                                               @Param("beginTime") LocalDateTime beginTime,
                                               @Param("reason") String reason,
                                               @Param("pageSize") int pageSize,@Param("offset") int offset,
                                               @Param("endTime") LocalDateTime endTime,
                                               @Param("cloudVendor")String cloudVendor);

    /**
     * 删除事件
     * @param beginTime
     */
    void delEventsByTime(@Param("beginTime")LocalDateTime beginTime);

    /**
     * 创建表
     */
    void createK8sEventTableIfNotExist();

    void delEventsByIp(@Param("k8sClusterIp")String k8sClusterIp);
}
